<template>
  <div class="container bg-color-white">
    <back-page :backType="true" />
    <swiper class="top-swiper" :indicator-dots="false" autoplay="true" interval="5000"
            duration="1000">
      <block v-for="(item, index) in listBanner" :key="index">
        <swiper-item>
          <img v-if="fileSpace" mode="aspectFill" class="width-375 height-175" :src="item"/>
        </swiper-item>
      </block>
    </swiper>
    <div class="top-info pad-l-12 pad-r-12">
      <div class="text-align-c">
        <img v-if="fileSpace && goodsEnterprise.enterpriseLogo" mode="aspectFill" class="userinfo-avatar mar-r-17 mar-t--12 bg-color-white"
            :src="goodsEnterprise.enterpriseLogo"/>        
      </div>
      <div class="text-align-c pad-t-5">
        <p class="font-w font-15">{{ goodsEnterprise.enterpriseName }}</p>
      </div>
      <div class="text-align-c certificate-content pad-20">
        <div v-for="(item, index) in certifiPicture" :key="index">
          <!-- <p class="pad-b-10">证件2</p> -->
          <img v-if="fileSpace && item" mode="widthFix" class="pad-b-10" :src="item"/>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {
    getProjectGoodsPage,
    getEnterpriseQualifications
  } from '@/api/distribution'
  import BackPage from '@/components/BackPage'
  export default {
    components: { BackPage },
    data() {
      return {
        goodsEnterprise: {},
        listBanner: [],
        enterpriseId: null,
        moreBrandBoolean: false,
        certifiPicture: []
      }
    },
    onLoad() {
      // 初始化data
      Object.assign(this.$data, this.$options.data())
    },
    onShow() {
      this.enterpriseId = this.getCurrentPage().query.enterpriseId
      this.getProjectGoodsPage()
    },
    methods: {
      getProjectGoodsPage() {
        getProjectGoodsPage({
          memberId: this.getCustomerId,
          enterpriseId: this.getEnterpriseId
        }).then((response) => {
          if (response.isError) return
          this.goodsEnterprise = response.data
          this.listBanner = []
          response.data.goodsBannerDTOS.forEach((banner) => {
            this.listBanner.push(banner.bannerImage)
          })
          if (this.listBanner.length === 0) {
            // 默认banner
            this.listBanner.push(this.fileSpace + '/images/1-2-banner.png')
          }
        }).catch(() => {
        })
        getEnterpriseQualifications({
          enterpriseId: this.getEnterpriseId
        }).then((response) => {
          if (response.isError) return
          this.certifiPicture = []
          response.data.enterpriseQualificationsImages.forEach((banner) => {
            this.certifiPicture.push(banner.imageUrl)
          })
        }).catch(() => {
        })
      }
    }
  }
</script>

<style lang="less" scoped>
  .userinfo-avatar{
    width: 90px;
    height: 90px;
    display: inline-block;
    border-radius: 8px;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 20;
  }
  .container{
    min-height: 100vh;
  }
  .certificate-content{
    image{
      width: 100%;
    }
  }
</style>
